# -*- coding: utf-8 -*-
# @Time    : 2021/12/6 20:51
# @Author  : rqdmy
# @Site    : 
# @File    : redis.py
# @Software: PyCharm

# import time
#
# import redis
#
# conn = redis.StrictRedis(host='192.168.0.13', port=6379, password='rqdmy0', encoding='utf-8')
# conn.set('18631731689', 9999, ex=10)
# value = conn.get('18631731689')
# print(value)
# time.sleep(12)
# print(value)


import time
import redis

conn = redis.Redis(host='192.168.0.13', port=6379, password='rqdmy0', encoding='utf-8')
conn.set('name', '蒋乐哥哥', ex=10)
# conn.expire('name', 10)
# 设置键的过期时间为10s
for item in range(12):
    value = conn.get('name')
    if value != None:
        print(value.decode('utf8'))
    else:
        print('the key has been deleted...')
        break
    time.sleep(1)
